package org.jivesoftware.smack.packet;

import org.jivesoftware.smack.util.StringUtils;

public class Presence extends Packet
{
  private Type type = Type.available;
  private String status = null;
  private int priority = -2147483648;
  private Mode mode = null;
  private String language;
  private long imLoginTime = 0L;
  private long chatLoginTime = 0L;

  public Presence(Type paramType)
  {
    setType(paramType);
  }

  public Presence(Type paramType, String paramString, int paramInt, Mode paramMode)
  {
    setType(paramType);
    setStatus(paramString);
    setPriority(paramInt);
    setMode(paramMode);
  }

  public boolean isAvailable()
  {
    return this.type == Type.available;
  }

  public boolean isAway()
  {
    return (this.type == Type.available) && ((this.mode == Mode.away) || (this.mode == Mode.xa) || (this.mode == Mode.dnd));
  }

  public Type getType()
  {
    return this.type;
  }

  public void setType(Type paramType)
  {
    if (paramType == null)
      throw new NullPointerException("Type cannot be null");
    this.type = paramType;
  }

  public String getStatus()
  {
    return this.status;
  }

  public void setStatus(String paramString)
  {
    this.status = paramString;
  }

  public int getPriority()
  {
    return this.priority;
  }

  public void setPriority(int paramInt)
  {
    if ((paramInt < -128) || (paramInt > 128))
      throw new IllegalArgumentException("Priority value " + paramInt + " is not valid. Valid range is -128 through 128.");
    this.priority = paramInt;
  }

  public Mode getMode()
  {
    return this.mode;
  }

  public void setMode(Mode paramMode)
  {
    this.mode = paramMode;
  }

  public String getLanguage()
  {
    return this.language;
  }

  public void setLanguage(String paramString)
  {
    this.language = paramString;
  }

  public void setImLoginTime(long paramLong)
  {
    this.imLoginTime = paramLong;
  }

  public void setChatLoginTime(long paramLong)
  {
    this.chatLoginTime = paramLong;
  }

  public String toXML()
  {
    StringBuilder localStringBuilder = new StringBuilder();
    localStringBuilder.append("<presence");
    if (getXmlns() != null)
      localStringBuilder.append(" xmlns=\"").append(getXmlns()).append("\"");
    if (this.language != null)
      localStringBuilder.append(" xml:lang=\"").append(getLanguage()).append("\"");
    if (getPacketID() != null)
      localStringBuilder.append(" id=\"").append(getPacketID()).append("\"");
    if (getTo() != null)
      localStringBuilder.append(" to=\"").append(StringUtils.escapeForXML(getTo())).append("\"");
    if (getFrom() != null)
      localStringBuilder.append(" from=\"").append(StringUtils.escapeForXML(getFrom())).append("\"");
    if (this.type != Type.available)
      localStringBuilder.append(" type=\"").append(this.type).append("\"");
    localStringBuilder.append(">");
    if (this.status != null)
      localStringBuilder.append("<status>").append(StringUtils.escapeForXML(this.status)).append("</status>");
    if (this.priority != -2147483648)
      localStringBuilder.append("<priority>").append(this.priority).append("</priority>");
    if ((this.mode != null) && (this.mode != Mode.available))
      localStringBuilder.append("<show>").append(this.mode).append("</show>");
    if (this.imLoginTime != 0L)
      localStringBuilder.append("<im_login_time>").append(this.imLoginTime).append("</im_login_time>");
    if (this.chatLoginTime != 0L)
      localStringBuilder.append("<chat_login_time>").append(this.chatLoginTime).append("</chat_login_time>");
    localStringBuilder.append(getExtensionsXML());
    XMPPError localXMPPError = getError();
    if (localXMPPError != null)
      localStringBuilder.append(localXMPPError.toXML());
    localStringBuilder.append("</presence>");
    return localStringBuilder.toString();
  }

  public String toString()
  {
    StringBuilder localStringBuilder = new StringBuilder();
    localStringBuilder.append(this.type);
    if (this.mode != null)
      localStringBuilder.append(": ").append(this.mode);
    if (getStatus() != null)
      localStringBuilder.append(" (").append(getStatus()).append(")");
    return localStringBuilder.toString();
  }

  public static enum Mode
  {
    chat, available, away, xa, dnd;
  }

  public static enum Type
  {
    available, unavailable, subscribe, subscribed, unsubscribe, unsubscribed, error;
  }
}

/* Location:           D:\hygieia\userclient\common\libs\easemobchat_2.1.8.jar
 * Qualified Name:     org.jivesoftware.smack.packet.Presence
 * JD-Core Version:    0.6.1
 */